package com.echat.business.book.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.echat.business.book.model.Announcement;
import com.echat.business.book.service.IAnnouncementService;
import com.echat.business.book.wrapper.AnnouncementWarpper;
import com.echat.core.constant.response.ResponseData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author chentl
 * @version V1.0
 * @Project AnnouncementController
 * @Title AnnouncementController.java
 * @Description 公告控制器
 * @Package com.echat.business.book.controller
 * @date 2019/6/6 13:24
 * @Copyright: 上海顺益信息科技有限公司 All rights reserved.
 */
@RestController
@Slf4j
@RequestMapping("/announcement")
public class AnnouncementController {
    @Autowired
    private IAnnouncementService announcementService;

    @RequestMapping(value = "/list")
    public ResponseData getAnnouncementList() {
        Wrapper<Announcement> wrapper = new EntityWrapper<>();
        wrapper.orderBy("id desc limit 5");
        List<Map<String, Object>> announcementList = new AnnouncementWarpper(announcementService.selectMaps(wrapper)).wrap();
        return new ResponseData(true, 200, "获取友情链接列表成功", announcementList);
    }
}
